In this article we will discuss to to demonstrate a prompt box in javascript. When the user click’s the button event will be raise it calls the javascript function there we have implement prompt box.
Example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>demonstrate theprompt box</title>
</head>
<body>
<p>Click the button to demonstratethe prompt box.</p>
<button onclick="myFunction()">Try it</button>
<p id="message"></p>
<script type="text/javascript">
function myFunction() {
var person = prompt("Please enter your name", "shahrukh khan");
if (person != null) {
document.getElementById("message").innerHTML=
"Hello " + person + "! How are you today?";
}
}
</script>
</body>
</html>
Output:
Post your comments / questions
Recent Article
- The request was aborted: Could not create SSL/TLS secure channel -Error in Asp.net
- FieldError: Cannot resolve keyword 'id' into field in Django project
- How to hide the ID field from the Django admin?
- It is impossible to add a non nullable field without specifying a default. Django error
- ImportError: cannot import name 'url' from 'django.conf.urls' - Django Error
- How to Enable Virtualization in BIOS Security Settings in Intel Processors For Android Studio?
- Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it.
- AttributeError: 'NoneType' object has no attribute 'get_text' - Python
Related Article